package client;

import when3meet.controller.AddChoiceController;
import when3meet.controller.AddEdgeController;
import when3meet.controller.AdminController;
import when3meet.controller.ConnectController;
import when3meet.controller.JoinController;
import when3meet.controller.KickController;
import when3meet.controller.RemoveController;
import when3meet.controller.ReportController;
import when3meet.controller.SignInController;
import when3meet.controller.CreateEventController;
import when3meet.controller.TurnResponseController;
import xml.Message;

/**
 * Sample implementation of a protocol handler to respond to messages received
 * from the server. You should follow this template when designing YOUR message
 * handler.
 */
public class ClientMessageHandler implements IMessageHandler {

	public void process(Message response) {
		String type = response.contents.getFirstChild().getLocalName();

		if (type.equals("connectResponse")) {
			new ConnectController().process();
		} else if (type.equals("createResponse")) {
			new CreateEventController(null).process(response);
		} else if (type.equals("addChoiceResponse")) {
			new AddChoiceController(null).process(response);
		} else if (type.equals("addEdgeResponse")) {
			new AddEdgeController(null).process(response);
		} else if (type.equals("adminResponse")) {
			new AdminController().process(response);
		} else if (type.equals("kickResponse")) {
			new KickController(null).process(response);
		} else if (type.equals("joinResponse")) {
			new JoinController().process(response);
		} else if (type.equals("removeResponse")) {
			new RemoveController().process(response);
		} else if (type.equals("reportResponse")) {
			new ReportController().process(response);
		} else if (type.equals("signInResponse")) {
			new SignInController(null).process(response);
		} else if (type.equals("turnResponse")) {
			new TurnResponseController().process(response);
		}

		// only here to show messages as they are received by the client
		// this isn't needed.
		System.out.println("Received:" + response);
	}

}
